package me.jessyan.mvparms.demo.mvp.presenter.fragment;

import android.app.Application;
import android.content.Intent;

import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.utils.PermissionUtil;
import com.tbruyelle.rxpermissions2.RxPermissions;

import java.util.ArrayList;
import java.util.List;

import me.jessyan.mvparms.demo.mvp.ui.activity.other.ScanCodeActivity;
import me.jessyan.mvparms.demo.utils.AvoidOnResult;
import me.jessyan.mvparms.demo.utils.MyMultiImageSelector;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;

import javax.inject.Inject;

import me.jessyan.mvparms.demo.mvp.contract.fragment.LifeContract;

import static android.app.Activity.RESULT_OK;


@FragmentScope
public class LifePresenter extends BasePresenter<LifeContract.Model, LifeContract.View> {
    @Inject
    RxErrorHandler mErrorHandler;
    @Inject
    Application mApplication;
    @Inject
    ImageLoader mImageLoader;
    @Inject
    AppManager mAppManager;

    @Inject
    public LifePresenter(LifeContract.Model model, LifeContract.View rootView) {
        super(model, rootView);
    }

    /**
     * 扫码
     */
    public  void scanCode(){
        //请求相机权限
        PermissionUtil.launchCamera(new PermissionUtil.RequestPermission() {
            @Override
            public void onRequestPermissionSuccess() {
               mRootView.getActvit().startActivity(new Intent(mRootView.getActvit(), ScanCodeActivity.class));
            }

            @Override
            public void onRequestPermissionFailure(List<String> permissions) {

            }

            @Override
            public void onRequestPermissionFailureWithAskNeverAgain(List<String> permissions) {

            }
        }, mRootView.getRxPermissions(), mErrorHandler);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mErrorHandler = null;
        this.mAppManager = null;
        this.mImageLoader = null;
        this.mApplication = null;
    }
}
